﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WindowsFormsApp1
{
    class Dphelp
    {
        public static readonly string connStr = "server=.;database=goods;uid=sa;pwd=123456";

       
        public static DataTable GetDataTable(string sql)
        {
            SqlConnection conn = new SqlConnection(connStr);

            conn.Open();

            SqlDataAdapter sda = new SqlDataAdapter(sql, connStr);

            DataTable dt = new DataTable();

            sda.Fill(dt);

            return dt;
        }

        
        public static bool AddorUpdateorDelete(string sql)
        {
            SqlConnection conn = new SqlConnection(connStr);

            conn.Open();

            SqlCommand cmd = new SqlCommand(sql, conn);

            int result = cmd.ExecuteNonQuery();

            return result > 0;

        }
    }
}
